package edu.gyc.hiblog.config;


import com.jagregory.shiro.freemarker.ShiroTags;
import edu.gyc.hiblog.templates.TopPostTemplate;
import edu.gyc.hiblog.templates.WeekRankTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Configuration
public class FreemarkerConfig {
    @Autowired
    private freemarker.template.Configuration configuration;

    @Autowired
    TopPostTemplate postTemplate;
    @Autowired
    WeekRankTemplate weekRankTemplate;

    @PostConstruct
    public void setUp() {

        configuration.setSharedVariable("posts",postTemplate);
        configuration.setSharedVariable("hots",weekRankTemplate);
        configuration.setSharedVariable("shiro",new ShiroTags());
    }
}
